#!/usr/bin/python3
#! -*- coding:utf-8 -*-

import random
from caltime import runtime


@runtime
def bubble_sort(ls):
    for i in range(len(ls) - 1):
        exchange = False
        for j in range(len(ls) - i - 1):
            if ls[j + 1] > ls[j]:
                ls[j], ls[j + 1] = ls[j + 1], ls[j]
                exchange = True
        if not exchange:
            return


lst = [random.randint(-1000, 1000) for _ in range(10)]
print('原列表>>>', lst)
bubble_sort(lst)
print('排序后的列表>>>', lst)

